// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   NseerParent.java

package include.tree_index;

import com.sun.crypto.provider.SunJCE;
import java.security.*;
import javax.crypto.*;
import javax.crypto.spec.DESKeySpec;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

public class NseerParent
{

	private SecretKey deskey;
	private Cipher c;

	public NseerParent()
	{
		init();
	}

	public void init()
	{
		Security.addProvider(new SunJCE());
		try
		{
			String key = "nSe@68er";
			DESKeySpec desKeySpec = new DESKeySpec(key.getBytes("UTF-8"));
			SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
			deskey = keyFactory.generateSecret(desKeySpec);
			c = Cipher.getInstance("DES");
		}
		catch (NoSuchAlgorithmException ex)
		{
			ex.printStackTrace();
		}
		catch (NoSuchPaddingException ex)
		{
			ex.printStackTrace();
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}

	public String E(String str)
	{
		String a = "";
		try
		{
			c.init(1, deskey);
			byte cipherByte[] = c.doFinal(str.getBytes("UTF-8"));
			a = (new BASE64Encoder()).encode(cipherByte);
		}
		catch (InvalidKeyException ex)
		{
			ex.printStackTrace();
		}
		catch (BadPaddingException ex)
		{
			ex.printStackTrace();
		}
		catch (IllegalBlockSizeException ex)
		{
			ex.printStackTrace();
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
		return a;
	}

	public String D(String str)
	{
		String a = "";
		try
		{
			byte b[] = (new BASE64Decoder()).decodeBuffer(str);
			c.init(2, deskey);
			byte cipherByte[] = c.doFinal(b);
			a = new String(cipherByte, "UTF-8");
		}
		catch (InvalidKeyException ex)
		{
			ex.printStackTrace();
		}
		catch (BadPaddingException ex)
		{
			ex.printStackTrace();
		}
		catch (IllegalBlockSizeException ex)
		{
			ex.printStackTrace();
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
		return a;
	}
}
